<?php
namespace Home\Model;
use Think\Model\RelationModel;;
class UserModel extends RelationModel {

  protected $_map=array(
	 "username"=>"user_name",
	 "userpsd"=>"user_password",
	 "useremail"=>"user_email",
	);

  //获取订单数
  function order_num(){
  	 
  	 //未支付的数量
     $num['no_pay']=M("Oorder")->where($this->order_condition("no_pay"))->count();
     //待收货的数量
     $num['wait_recevie']=M("Oorder")->where($this->order_condition("wait_recevie"))->count();
     //待自取的数量
     $num['wait_get']=M("Oorder")->where($this->order_condition("wait_get"))->count();
     //待评价的数量
     $num['wait_commit']=M("Oorder")->where($this->order_condition("wait_commit"))->count();
     //所有评价的数量
     $num['all']=M("Oorder")->where($this->order_condition("all"))->count();
     return $num;
  }

  function order_condition($tab){
  	$uid=is_login();
     if($tab=="no_pay")$condition=array("uid"=>$uid,"pay_way"=>1,"pay_result"=>0);
     elseif($tab=="wait_recevie")$condition=array("uid"=>$uid,"send_way"=>1);
     elseif($tab=="wait_get")$condition=array("uid"=>$uid,"send_way"=>2);
     elseif($tab=="wait_commit")$condition=array("uid"=>$uid,"status"=>8);
     elseif($tab=='all') $condition=array("uid"=>$uid);
     return $condition;

  }

}
?>